/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hcbank.jpa.entities.helper;

import com.hcbank.classes.Account;
import com.hcbank.classes.Transaction;
import com.hcbank.jpa.entities.TransactionEntity;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author NHAHV
 */
public class TransactionHelper {
    
    public Transaction toTransaction(TransactionEntity te){
        Transaction t = new Transaction();
        try {
              t.setId(te.getId());
        t.setAmount(te.getAmount());
        t.setTransactionTime(te.getTransactionTime());
        if(te.getFromAccount() != null){
            t.setFromAccount(te.getFromAccount().getId());
                    }
        if(te.getToAccount()!= null){
            t.setToAccount(te.getToAccount().getId());
        }
        
        t.setStatus(te.getStatus());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return t;
        }
      
        
    }
    
  
}
